/**
 * 
 */
package spl.utils;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Properties;
//import com.google.common.base.CaseFormat;

/**
 * @author Ruby
 *
 */
public class FileProperties extends Properties {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	/**
	 * @param filename in disk of prop file
	 * @throws IOException on other IO error
	 * @throws FileNotFoundException when file is not found on disk
	 */
	public FileProperties(String filename) throws FileNotFoundException, IOException {
		super();
		this.load(new FileInputStream(filename));
	}
	
	/**
	 * Builds the property key from it's index, type and name.
	 * i.e (0, s, Name) --> s0Name
	 * @param index of property
	 * @param type of property.
	 * @param property name. Prefer CapitalizedCamel format, even if the property is lowerCamelCased.
	 * @return the value associated with it.
	 */
	public String getProperty(int index, String type, String property) {
		String absProperty = type + Integer.toString(index) + property;
		String result =  this.getProperty(absProperty);
		
		if(null == result) {
			//property = CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_CAMEL, property);
			
			absProperty = type + Integer.toString(index) + property;
			return this.getProperty(absProperty);
		}
		
		return result;
	}

}
